home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / Draw / Sources / PrintHdl.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  3.0 KB  |  102 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                PrintHdl.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef PRINTHDL_H
  15. #include "PrintHdl.h"
  16. #endif
  17.  
  18. #ifndef DRAWFRM_H
  19. #include "DrawFrm.h"
  20. #endif
  21.  
  22. #ifndef DRAWCONT_H
  23. #include "DrawCont.h"
  24. #endif
  25.  
  26. #ifndef FWPART_H
  27. #include "FWPart.h"
  28. #endif
  29.  
  30. #ifndef FWPRESEN_H
  31. #include "FWPresen.h"
  32. #endif
  33.  
  34. //========================================================================================
  35. // RunTime Info
  36. //========================================================================================
  37.  
  38. #ifdef FW_BUILD_MAC
  39. #pragma segment odfdrawframes
  40. #endif
  41.  
  42. //========================================================================================
  43. // CDrawPrintHandler
  44. //========================================================================================
  45.  
  46. //----------------------------------------------------------------------------------------
  47. // CDrawPrintHandler::CDrawPrintHandler
  48. //----------------------------------------------------------------------------------------
  49.  
  50. CDrawPrintHandler::CDrawPrintHandler(Environment* ev, CDrawFrame* frame, CDrawPartContent* content, FW_CPresentation* presentation) :
  51.     FW_CPrintHandler(content->GetPart(ev), frame),
  52.     fDrawFrame(frame),
  53.     fPartContent(content),
  54.     fPrintPresentation(presentation)
  55. {
  56. }
  57.  
  58. //----------------------------------------------------------------------------------------
  59. // CDrawPrintHandler::~CDrawPrintHandler
  60. //----------------------------------------------------------------------------------------
  61.  
  62. CDrawPrintHandler::~CDrawPrintHandler()
  63. {
  64. }
  65.  
  66. //----------------------------------------------------------------------------------------
  67. //    CDrawPrintHandler::IsCurrentlyPrintable
  68. //----------------------------------------------------------------------------------------
  69.  
  70. FW_Boolean CDrawPrintHandler::IsCurrentlyPrintable(Environment* ev) const
  71. {
  72.     return !fPartContent->IsEmpty();
  73. }
  74.  
  75. //----------------------------------------------------------------------------------------
  76. //    CDrawPrintHandler::GetPrintContentExtent
  77. //----------------------------------------------------------------------------------------
  78.  
  79. void CDrawPrintHandler::GetPrintContentExtent(Environment *ev, FW_CPoint& extent) const
  80. {
  81.     // We only enable print command if there is anything to print
  82.     FW_ASSERT(IsCurrentlyPrintable(ev));
  83.  
  84.     // Go through all the shapes and determine their bounds
  85.     extent.Set(FW_kFixed0, FW_kFixed0);
  86.     CDrawContentShapeIterator ite(fPartContent);
  87.     for (CBaseShape* theShape = ite.First(); ite.IsNotComplete(); theShape = ite.Next())
  88.     {
  89.         FW_CRect updateBox;
  90.         theShape->GetUpdateBox(updateBox);
  91.  
  92.         if (updateBox.right > extent.x)
  93.             extent.x = updateBox.right;
  94.         
  95.         if (updateBox.bottom > extent.y)
  96.             extent.y = updateBox.bottom;
  97.     }
  98.     
  99.     FW_ASSERT(extent.x != FW_kFixed0);
  100.     FW_ASSERT(extent.y != FW_kFixed0);
  101. }
  102.